<template>
  <div style="z-index: 11;">
    <el-button round type="primary" icon="save" @click="save">保存</el-button>
    <el-button v-if="showPreviewFlowButton" round icon="view" @click="previewFlow">查看流程</el-button>

    <FlowModelWithHistory ref="refFlowModelWithHistory"/>
  </div>
</template>
<script setup>
import {computed, shallowRef} from 'vue';
import FlowModelWithHistory from '@/components/platwork/FlowModelWithHistory';
import {isNotEmpty} from '@/utils/CommonUtils';

const emits = defineEmits(['save'])
const props = defineProps({
  formDataVoRef: undefined
});
const refFlowModelWithHistory = shallowRef();

function previewFlow() {
  refFlowModelWithHistory.value.setData(props.formDataVoRef.formData.process_instance_id);
}

const showPreviewFlowButton = computed(() => {
  if (isNotEmpty(props.formDataVoRef)
      && isNotEmpty(props.formDataVoRef.formData)
      && isNotEmpty(props.formDataVoRef.formData.process_instance_id)) {
    return true;
  }
  return false;
});

function save() {
  emits('save')
}

</script>